<?php

class DateUtil {

	/**
	 *
	 * @param Timestamp $date
	 * @param Array $intervals
	 * Available interval format
	 * [seconds] => 40
	 * [minutes] => 58
	 * [hours]   => 21
	 * [mday]    => 17
	 * [wday]    => 2
	 * [mon]     => 6
	 * [year]    => 2003
	 * [yday]    => 167
	 * [weekday] => Tuesday
	 * [month]   => June
	 * [0]       => 1055901520
	 */
	public static function add( $date, $intervals ) {

		$params = getdate( $date );

		$hours = $intervals['hours']? $intervals['hours']: $params['hours'];
		$minutes = $intervals['minutes']? $intervals['minutes']: $params['minutes'];
		$seconds = $intervals['seconds']? $intervals['seconds']: $params['seconds'];
		$mon = $intervals['mon']? $intervals['mon']: $params['mon'];
		$mday = $intervals['mday']? $intervals['mday']: $params['mday'];
		$year = $intervals['year']? $intervals['year']: $params['year'];

		$newdate  = mktime($hours, $minutes, $seconds, $mon  , $mday, $year);

		return $newdate;
	}
}